package com.example.safeassistan.ui.login.fragment;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;


import com.example.safeassistan.R;
import com.example.safeassistan.base.BaseVPFragment;

import java.util.ArrayList;
import java.util.List;

@SuppressLint("ValidFragment")
public class GuideFragment extends BaseVPFragment {

    private ImageView image;
    private List<Integer> mImgs;
    private int mPosition;

    @Override
    protected void onFragmentVisibleChange(boolean isVisible) {

    }

    @Override
    protected void onFragmentFirstVisible() {

    }

    public GuideFragment(int position, List<Integer> imgs) {
        this.mPosition = position;
        this.mImgs = imgs;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_guide, container, false);

        initView(view);
        return view;
    }

    private void initView(View view) {

        image = view.findViewById(R.id.image);

        if (mImgs == null) mImgs = new ArrayList<>();
        if (mImgs.size() <= mPosition) return;

        setImg(mPosition);
        image.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(mPosition==mImgs.size()-1){
                  //  MainActivity.actionStart(getContext());
                }
            }
        });
    }

    public void setImg(int position) {
        image.setImageDrawable(getActivity().getResources().getDrawable(mImgs.get(position)));
    }
}
